package juc.AtomicDemo;

import java.util.concurrent.atomic.AtomicInteger;

/**
 * @author liuchaoqun
 * @date 2022/8/26
 * @Description
 */
public class AtomicResource implements Runnable{
//    private AtomicInteger serialNumber = new AtomicInteger(0);
    private volatile int serialNumber = 0;


    @Override
    public void run() {
        try {
            Thread.sleep(200);
        } catch (InterruptedException e) {
        }
        System.out.print(getSerialNumber()+" ");
    }
    public int getSerialNumber(){
        return serialNumber++;
//        return serialNumber.getAndIncrement();
    }

}
